﻿<Window x:Class="Continents_Countries_Cities.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"
        xmlns:vm="clr-namespace:WPF_Databases.ViewModels"        
        >
    <Window.Resources>
        <vm:ViewModelMain x:Key="vmMain"/>
    </Window.Resources>

    <StackPanel DataContext="{Binding Source={StaticResource vmMain}}">
        <ComboBox x:Name="ComboBoxCountries" ItemsSource="{Binding Continnents}" DisplayMemberPath="ContinentName"/>
        <ListView x:Name="ListViewCountries" ItemsSource="{Binding SelectedItem.Countries, ElementName=ComboBoxCountries}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBox Text="{Binding CountryName}"/>
                        <TextBox Text="{Binding Population}"/>
                        <Image Source="{Binding Flag}" MaxWidth="150"/>
                        <Button Content="Change Picture" Command="{Binding ChangePictureCommand,
                            Source={StaticResource vmMain}}" 
                                CommandParameter="{Binding DataContext,RelativeSource={RelativeSource Self}}"/>
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
        <Button x:Name="ButtonSave" Command="{Binding SaveCommand}" Content="Save Changes!"/>
    </StackPanel>
</Window>